package com.mqtt.ctwingmqtt.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.sql.Timestamp;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@TableName("device")
@ApiModel(description = "设备实体类")
public class DeviceEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "主键ID", example = "1")
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "device_code", nullable = false, length = 50)
    @ApiModelProperty(value = "设备编号", example = "D12345")
    private String deviceCode;

    @Column(name = "device_address", nullable = false, length = 50)
    @ApiModelProperty(value = "设备地址", example = "DEV12345")
    private String deviceAddress;

    @Column(name = "status", nullable = false, length = 10)
    @ApiModelProperty(value = "设备状态（在线/离线）", example = "在线")
    private String status;

    @Column(name = "device_name", nullable = false, length = 50)
    @ApiModelProperty(value = "设备名称", example = "设备名称")
    private String deviceName;

    @Column(name = "dtu_id", nullable = false)
    @ApiModelProperty(value = "关联DTU表的ID（逻辑外键）", example = "1")
    private Long dtuId;

    @Column(name = "dtu_name", nullable = false, length = 50)
    @ApiModelProperty(value = "关联DTU表的名称（逻辑外键）", example = "DTU名称")
    private String dtuName;

    @Column(name = "createtime", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "创建时间", example = "2023-10-01 12:34:56")
    private Timestamp createtime;

    @Column(name = "updatetime", nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "更新时间", example = "2023-10-01 12:34:56")
    private Timestamp updatetime;

    @Column(name = "device_type", nullable = false)
    @ApiModelProperty(value = "设备类型", example = "阀门")
    private String deviceType;

    @Column(name = "product_id", nullable = false)
    @ApiModelProperty(value = "产品id", example = "")
    private String productId;


}
